import sys
from PyQt5.QtCore import Qt, QSize, QUrl
from PyQt5.QtGui import QIcon, QDesktopServices, QFont, QColor,QPixmap
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QVBoxLayout
from qfluentwidgets import *
from fuc_desktop.fuc_system.sys_messages import *
from fuc_desktop.fuc_system.sys_repair import *
from fuc_desktop.fuc_software.software_related import *
from fuc_desktop.fuc_software.software_repairs import *
import ico_rc


class kytools_main_menu(MSFluentWindow):

    def __init__(self, parent=None):
        super().__init__(parent)
        self.sysMessages = sys_messages(self)
        # self.systemRepair = system_repair(self)
        # self.softwareRepairs = software_repairs(self)
        self.softwareRelated = software_related(self)

        self.initNavigation()
        self.initWindow()

    def initNavigation(self):
        self.addSubInterface(self.sysMessages, FluentIcon.HOME,'系统信息', selectedIcon=FluentIcon.HOME_FILL)
        # self.addSubInterface(self.systemRepair, FluentIcon.BROOM, '修复系统')
        # self.addSubInterface(self.softwareRepairs, FluentIcon.DEVELOPER_TOOLS, '软件源商店')
        self.addSubInterface(self.softwareRelated, FluentIcon.APPLICATION, '软件处理')
        # self.addSubInterface('打印机', FluentIcon.PRINT, '打印机')
        # self.addSubInterface('其他', FluentIcon.BRUSH, '其他')
        # self.addSubInterface('服务器', FluentIcon.CONNECT, '服务器')
        self.navigationInterface.addItem('Help',FluentIcon.HELP,'帮助',onClick=self.showMessageBox,position=NavigationItemPosition.BOTTOM)
        self.stackedWidget.setStyleSheet('QWidget{background: transparent}')

    def initWindow(self):
        self.resize(900, 700)
        self.setWindowTitle('麒麟民间工具箱')
        icon = QIcon()
        icon.addPixmap(QPixmap(":/kylinico/kylinico"), QIcon.Normal, QIcon.Off)
        self.setWindowIcon(icon)
        desktop = QApplication.desktop().availableGeometry()
        w, h = desktop.width(), desktop.height()
        self.move(w//2 - self.width()//2, h//2 - self.height()//2)

    def showMessageBox(self):
        w = MessageBox(
            '查看文档',
            '点击查看公司同事整理的文档',
            self
        )
        w.yesButton.setText('查看')
        w.cancelButton.setText('取消')
        if w.exec():
            QDesktopServices.openUrl(QUrl("https://picw44f89kf.feishu.cn/wiki/W3BRw6XENiyMP9kemBbcoesHnWI"))

if __name__ == '__main__':
    QApplication.setHighDpiScaleFactorRoundingPolicy(
        Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
    app = QApplication(sys.argv)
    w = kytools_main_menu()
    w.show()
    app.exec_()